from dvadmin.utils.viewset import CustomModelViewSet

from se_admin.tables.AssetTables.models import SeAssets
from se_admin.tables.AssetTables.serializers import SeAssetsSerializer, SeAssetsCreateUpdateSerializer, SeAssetsImportSerializer, SeAssetsExportSerializer
from se_admin.tables.AssetTables.serializers import AssetTypeSerializer, AssetStatusSerializer

# 资产类型字典
class AssetTypeViewSet(CustomModelViewSet):
    """
    list:查询
    create:新增
    update:修改
    retrieve:单例
    destroy:删除
    """
    queryset = AssetTypeSerializer.Meta.model.objects.all()
    serializer_class = AssetTypeSerializer

# 资产状态字典
class AssetStatusViewSet(CustomModelViewSet):
    """
    list:查询
    create:新增
    update:修改
    retrieve:单例
    destroy:删除
    """
    queryset = AssetStatusSerializer.Meta.model.objects.all()
    serializer_class = AssetStatusSerializer

class SeAssetsViewSet(CustomModelViewSet):
    """
    list:查询
    create:新增
    update:修改
    retrieve:单例
    destroy:删除
    """
    queryset = SeAssets.objects.all()
    serializer_class = SeAssetsSerializer
    create_serializer_class = SeAssetsCreateUpdateSerializer
    update_serializer_class = SeAssetsCreateUpdateSerializer

    filter_class = None

    export_field_label = {
        'asid': '资产编号',
        'astype': '资产类型',
        'asmodel': '资产型号',
        'assn': '序列号',
        'asstatus': '资产状态',
        'is_ems': 'EMS状态',
        'is_myfa': 'MYFA状态',
        'manufacturer': '制造商',
        'lc_code': '位置编码',
        'lc_rack': '机柜编号',
        'lc_dtl': '机架位置',
        'order_pr': 'PR单号',
        'order_item': '资产料号',
        'order_po': 'PO单号',
        'order_price': '订单价格',
        'order_dtl': '订单详情',
        'admin': '管理员',
        'memo': '备注',
        'update_datetime': '更新时间',
    }
    export_serializer_class = SeAssetsExportSerializer

    import_field_dict = {
        'asid': '资产编号',
        'astype': '资产类型',
        'asmodel': '资产型号',
        'assn': '序列号',
        'asstatus': '资产状态',
        'is_ems': 'EMS状态',
        'is_myfa': 'MYFA状态',
        'manufacturer': '制造商',
        'lc_code': '位置编码',
        'lc_rack': '机柜编号',
        'lc_dtl': '机架位置',
        'order_pr': 'PR单号',
        'order_item': '资产料号',
        'order_po': 'PO单号',
        'order_price': '订单价格',
        'order_dtl': '订单详情',
        'admin': '管理员',
        'memo': '备注',
    }
    import_serializer_class = SeAssetsImportSerializer



